<?php

use Doctrine\ORM\EntityManager,
    Doctrine\ORM\Configuration;

require_once  'lib/Doctrine/ORM/Tools/Setup.php';

$lib = "lib";
\Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($lib);

$applicationMode = "development";

if ($applicationMode == "development") {
    $cache = new \Doctrine\Common\Cache\ArrayCache;
} else {
    $cache = new \Doctrine\Common\Cache\ApcCache;
}

$config = new Configuration;
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver('db/Entity');
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir('db/Proxy');
$config->setProxyNamespace('db/Proxy');

if ($applicationMode == "development") {
    $config->setAutoGenerateProxyClasses(true);
} else {
    $config->setAutoGenerateProxyClasses(false);
}

$connectionOptions = array(
    'driver' => 'pdo_mysql',
    'dbname' => 'sim',
    'user' => 'root',
    'password' => '',
    'host' => 'localhost',
    'port' => '3306',
    'charset' => 'utf8'
);

$em = EntityManager::create($connectionOptions, $config);
?>
